<!--混凝土拌和站---动态监控--实时监控-->
<!--
 * @Author: 卡卡 1071780426@qq.com
 * @Date: 2022-12-02 13:13:25
 * @LastEditors: 卡卡 1071780426@qq.com
 * @LastEditTime: 2023-10-26 17:10:29
 * @FilePath: \backstage - 副本\src\views\aa.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
    <div class="department" id="department">

        <!-- 右侧 -->
        <div class="department_right">
            <div class="app-container-btn">
                <el-button @click="goBack">返回</el-button>
            </div>
            <!-- 表格 -->
            <div class="text_table TensionRealTime">
                <!-- navigatepageNums > 1   height="calc(100% - 50px)"-->
                <!-- <div :id="('select' + index)" v-for="(item, index) in tableData" :key="index">12</div> -->
                <div class="dialogBody common table_detail">
                    <div class="app-container-area-title">
                        <span class="app-container-area-title-divider"></span>
                        <span>基本信息</span>
                    </div>
                    <div>
                        <publicForm ref="publicForm" lableWidth="95px" :formObj="formObj" :formData="formData">
                        </publicForm>
                    </div>
                    <div class="app-container-area-title">
                        <span class="app-container-area-title-divider"></span>
                        <span>材料用量</span>
                    </div>

                    <div style=" margin-top: 8px" class="levelClass materialClass">
                        <tableData :config="material_config" :dataList="materialData" statusType="2" :level="level"
                            :earlyWarning="earlyWarning" :currentRow="false" :stripe="false" />
                    </div>
                </div>
            </div>


        </div>
    </div>
</template>
    
<script>
import actions from "@/actions";

// import vDatePicker from "@/components/public/v-DatePicker";
import tree from "@/components/public/el-trees"; //左侧机构树
import TableData from "@/components/public/el-tables"; //主页面列表
import Pagination from "@/components/public/el-pagination"; //主页面分页
import elBreadcrumb from "@/components/public/el-breadcrumb.vue"; //面包屑
import publicForm from "@/components/public/el-form.vue"; //弹框form

import formJs from "./regexDetail.js"; //新增弹框配置项
import {
    getUserCompanyTreeList, //左侧机构树接口
    getMixListByCompanyId, //主页面列表接口
    getMixInfoById, //主页面列表详情接口
    getStationmachineByfMachineid, //查询-拌合站信息-详情接口
    getStationmachineList, //拌合站列表
    getMachineListByStationId, //拌合机
} from "@/api/request.js";
import { statusType2 } from "@/utils/config"; //配置项
export default {
    name: "supervisionListDetail",
    data() {
        return {
            name: "supervisionListDetail", //按钮配置页面代号
            editLoading: false,
            timeDuring: "",
            pickerOptions: {
                disabledDate(time) {
                    return time.getTime() > Date.now();
                }
            },
            falgId: null,
            rowInfo: null,//当前行信息
            projectsObj: [],//项目名
            tendersObj: [],



            // yj_view: null,//查看按钮是否显示
            formObj: formJs.formObj, //新增编辑配置参数
            formData: {}, //新增编辑向后台传递对象
            navigatepageNums: null, //是否显示分页
            queryCriteriaData: {}, //分页
            defaultDate: "",

            strengthGradeDataList: formJs.strengthGradeDataList,
            djDataList: formJs.djDataList,
            CloseoperationDataList: formJs.CloseoperationDataList,
            level: [],
            earlyWarning: [],
            bhzDataList: [], //拌合站

            bhjDataList: [], //拌合机
            value2: "", //主页面日期筛选绑定值
            json_fields: formJs.json_fields,
            xlsxName: null,
            // 列表配置项
            table_config: formJs.table_config,

            tableData: [], //表格列表数据列表
            tableDatas: [], //导出所有数据
            material_config: formJs.material_config, //材料配置项
            materialData: [], //材料用量列表
            highlightBd: true, //左侧机构树停留背景色

            treelength: false, //左侧树显示隐藏
            checked: true, //查看下级按钮
            showName: "未选择公司",
            dialogHeight: "470px", //弹框高度
            fId: null, //点击当前列表数据fId
            listLoading: false, //列表数据加载loading
            loadingEditDialog: false, //弹框loading
            dialogEditVisible: false, //新增弹框是否显示
            // 列表给后端传参
            getList: formJs.getList,

            companyTree: "", //所有数据
            treeData: [], //左侧树状图数据

            // 左侧机构树
            defaultProps: {
                children: "children",
                label: "fShortname",
            },
            checkData: [],
            userInfo: {}, //登录用户
            treeText: {
                //树状图参数
                companyId: null,
                userId: null,
                text: null,
            },
        };
    },
    components: {
        // vDatePicker, //时间选择器
        tree, //左侧组织机构数
        TableData, //主页面列表
        elBreadcrumb, //面包屑
        publicForm, //弹框表格
        Pagination, //分页
        // selects,//下拉框
    },
    mounted() {
        actions.onGlobalStateChange((state, prev) => {
            this.projectsObj = prev.currentUser.projects
        }, true);
        this.yj_viewForm()
        this.userInfo = JSON.parse(sessionStorage.getItem("GxEmbedded_userInfo"));
        // this.getTree();
        if (JSON.parse(sessionStorage.getItem("GxEmbedded_getList"))) {
            this.getList = JSON.parse(sessionStorage.getItem("GxEmbedded_getList"));
            this.getbhjDataMethods(this.getList.stationId);
        }

        if (JSON.parse(sessionStorage.getItem("GxEmbedded_treeCheck"))) {
            var id = JSON.parse(sessionStorage.getItem("GxEmbedded_treeCheck"));
            this.checkData = [id.fCompanyid];
        }

        this.table_config.thead[6]["callback"] = function (rowData) {
            let data = statusType2[rowData.F_WarningLevel];
            if (data) {
                return data.label;
            }
        };
        this.table_config.thead[6]["specialClass"] = function (rowData) {
            let data = statusType2[rowData.F_WarningLevel];
            if (data) {
                return data.className;
            }
        };

        this.table_config.operation.cols = [
            {
                label: "查看",
                type: "primary",
                handleRow: this.handleRow,
            },
        ];

        // this.checkData = [id.fCompanyid];

        this.btnRole(this.name);
        this.getDate();
    },
    methods: {
        goBack() {
            this.$router.back()
        },
        // 点击当前行
        rowChange(val) {
            console.log(val);
        },



        // 查看
        yj_viewForm(row) {
            var row = JSON.parse(this.$route.query.data)

            this.fId = row.F_Id;
            var id = row.F_Id;
            this.fPhotofilelist = [];
            if (id != "" && id != null) {
                // this.dialogEditVisible = true;
                this.loadingEditDialog = false;

                getStationmachineByfMachineid({ machineId: row.F_MachineId })
                    .then((res1) => {
                        if (res1.errcode == 0) {
                            this.material_config.thead[4].label =
                                res1.data.yjQmpMsStationmachine.fParm1;
                            this.material_config.thead[5].label =
                                res1.data.yjQmpMsStationmachine.fParm2;
                            this.material_config.thead[6].label =
                                res1.data.yjQmpMsStationmachine.fParm3;
                            this.material_config.thead[7].label =
                                res1.data.yjQmpMsStationmachine.fParm4;
                            this.material_config.thead[8].label =
                                res1.data.yjQmpMsStationmachine.fParm5;

                            getMixInfoById({
                                fId: id,
                                fCompanyid: this.$route.query.fCompanyid,
                            }).then((res) => {
                                if (res.errcode == 0) {
                                    console.log(res.data);
                                    var that = this;
                                    that.loadingEditDialog = false;
                                    // that.dialogEditVisible = true;
                                    that.formData = res.data.dischargeinfo;
                                    this.materialData = [
                                        {
                                            // fCement2deviatevalue
                                            name: "设计重量值(kg)",
                                            water: res.data.dischargeinfo.fWaterdesignvalue,
                                            cement1: res.data.dischargeinfo.fCement1designvalue,
                                            cement2: res.data.dischargeinfo.fCement2designvalue,
                                            aggregate1: res.data.dischargeinfo.fAggregate1designvalue,
                                            aggregate2: res.data.dischargeinfo.fAggregate2designvalue,
                                            aggregate3: res.data.dischargeinfo.fAggregate3designvalue,
                                            aggregate4: res.data.dischargeinfo.fAggregate4designvalue,
                                            aggregate5: res.data.dischargeinfo.fAggregate5designvalue,
                                            oredesign: res.data.dischargeinfo.fOredesignvalue,
                                            flyash: res.data.dischargeinfo.fFlyashdesignvalue,
                                            admixture1: res.data.dischargeinfo.fAdmixture1designvalue,
                                            admixture2: res.data.dischargeinfo.fAdmixture2designvalue,
                                            // cement3: "",
                                        },
                                        {
                                            name: "实际称量值(kg)",
                                            water: res.data.dischargeinfo.fWateractualvalue,
                                            cement1: res.data.dischargeinfo.fCement1actualvalue,
                                            cement2: res.data.dischargeinfo.fCement2actualvalue,
                                            // cement3: "",
                                            aggregate1: res.data.dischargeinfo.fAggregate1actualvalue,
                                            aggregate2: res.data.dischargeinfo.fAggregate2actualvalue,
                                            aggregate3: res.data.dischargeinfo.fAggregate3actualvalue,
                                            aggregate4: res.data.dischargeinfo.fAggregate4actualvalue,
                                            aggregate5: res.data.dischargeinfo.fAggregate5actualvalue,
                                            oredesign: res.data.dischargeinfo.fOreactualvalue,
                                            flyash: res.data.dischargeinfo.fFlyashactualvalue,
                                            admixture1: res.data.dischargeinfo.fAdmixture1actualvalue,
                                            admixture2: res.data.dischargeinfo.fAdmixture2actualvalue,
                                        },
                                        {
                                            name: "重量偏差(%)",
                                            water: res.data.dischargeinfo.fWaterdeviatevalue, //水
                                            cement1: res.data.dischargeinfo.fCement1deviatevalue, //水泥1
                                            cement2: res.data.dischargeinfo.fCement2deviatevalue, //水泥2
                                            aggregate1:
                                                res.data.dischargeinfo.fAggregate1deviatevalue, //骨料1
                                            aggregate2:
                                                res.data.dischargeinfo.fAggregate2deviatevalue, //骨料2
                                            aggregate3:
                                                res.data.dischargeinfo.fAggregate3deviatevalue, //骨料3
                                            aggregate4:
                                                res.data.dischargeinfo.fAggregate4deviatevalue, //骨料4
                                            aggregate5:
                                                res.data.dischargeinfo.fAggregate5deviatevalue, //骨料5
                                            oredesign: res.data.dischargeinfo.fOredeviatevalue, //矿粉
                                            flyash: res.data.dischargeinfo.fFlyashdeviatevalue, //粉煤灰
                                            admixture1:
                                                res.data.dischargeinfo.fAdmixture1deviatevalue, //外加剂1
                                            admixture2:
                                                res.data.dischargeinfo.fAdmixture2deviatevalue, //外加剂2
                                        },
                                        {
                                            name: "",
                                            show: true,
                                            water: res.data.dischargeinfo.fWaterwarninginfo, //水
                                            cement1: res.data.dischargeinfo.fCement1warninginfo, //水泥1
                                            cement2: res.data.dischargeinfo.fCement2warninginfo, //水泥2
                                            aggregate1: res.data.dischargeinfo.fAggregate1warninginfo, //骨料1
                                            aggregate2: res.data.dischargeinfo.fAggregate2warninginfo, //骨料2
                                            aggregate3: res.data.dischargeinfo.fAggregate3warninginfo, //骨料3
                                            aggregate4: res.data.dischargeinfo.fAggregate4warninginfo, //骨料4
                                            aggregate5: res.data.dischargeinfo.fAggregate5warninginfo, //骨料5
                                            oredesign: res.data.dischargeinfo.fOrewarninginfo, //矿粉
                                            flyash: res.data.dischargeinfo.fFlyashwarninginfo, //粉煤灰
                                            admixture1: res.data.dischargeinfo.fAdmixture1warninginfo, //外加剂1
                                            admixture2: res.data.dischargeinfo.fAdmixture2warninginfo, //外加剂2
                                        },
                                    ];
                                    this.level = [
                                        "",
                                        res.data.dischargeinfo.fWaterwarninglevel,
                                        res.data.dischargeinfo.fCement1warninglevel,
                                        res.data.dischargeinfo.fCement2warninglevel,
                                        res.data.dischargeinfo.fAggregate1warninglevel,
                                        res.data.dischargeinfo.fAggregate2warninglevel,
                                        res.data.dischargeinfo.fAggregate3warninglevel,
                                        res.data.dischargeinfo.fAggregate4warninglevel,
                                        res.data.dischargeinfo.fAggregate5warninglevel,
                                        res.data.dischargeinfo.fOrewarninglevel,
                                        res.data.dischargeinfo.fFlyashwarninglevel,
                                        res.data.dischargeinfo.fAdmixture1warninglevel,
                                        res.data.dischargeinfo.fAdmixture2warninglevel,
                                    ];
                                    this.earlyWarning = [
                                        "",
                                        res.data.dischargeinfo.fWaterwarninginfo,
                                        res.data.dischargeinfo.fCement1warninginfo,
                                        res.data.dischargeinfo.fCement2warninginfo,
                                        res.data.dischargeinfo.fAggregate1warninginfo,
                                        res.data.dischargeinfo.fAggregate2warninginfo,
                                        res.data.dischargeinfo.fAggregate3warninginfo,
                                        res.data.dischargeinfo.fAggregate4warninginfo,
                                        res.data.dischargeinfo.fAggregate5warninginfo,
                                        res.data.dischargeinfo.fOrewarninginfo,
                                        res.data.dischargeinfo.fFlyashwarninginfo,
                                        res.data.dischargeinfo.fAdmixture1warninginfo,
                                        res.data.dischargeinfo.fAdmixture2warninginfo,
                                    ];

                                    var Cement1 = null; //水泥1
                                    if (
                                        res.data.dischargeinfo.fCement1actualvalue != null &&
                                        res.data.dischargeinfo.fCement1actualvalue != null
                                    ) {
                                        Cement1 = res.data.dischargeinfo.fCement1actualvalue - 0;
                                    } else {
                                        Cement1 = 0;
                                    }
                                    var Cement2 = null; //水泥2
                                    if (
                                        res.data.dischargeinfo.fCement2actualvalue != null &&
                                        res.data.dischargeinfo.fCement2actualvalue != null
                                    ) {
                                        Cement2 = res.data.dischargeinfo.fCement2actualvalue - 0;
                                    } else {
                                        Cement2 = 0;
                                    }
                                    var Oreactual = null; //矿粉
                                    if (
                                        res.data.dischargeinfo.fOreactualvalue != null &&
                                        res.data.dischargeinfo.fOreactualvalue != null
                                    ) {
                                        Oreactual = res.data.dischargeinfo.fOreactualvalue - 0;
                                    } else {
                                        Oreactual = 0;
                                    }
                                    var Flyashactual = null; //粉煤灰
                                    if (
                                        res.data.dischargeinfo.fFlyashactualvalue != null &&
                                        res.data.dischargeinfo.fFlyashactualvalue != null
                                    ) {
                                        Flyashactual =
                                            res.data.dischargeinfo.fFlyashactualvalue - 0;
                                    } else {
                                        Flyashactual = 0;
                                    }
                                    var Admixture1 = null; //外加剂1
                                    if (
                                        res.data.dischargeinfo.fAdmixture1actualvalue != null &&
                                        res.data.dischargeinfo.fAdmixture1actualvalue != null
                                    ) {
                                        Admixture1 =
                                            res.data.dischargeinfo.fAdmixture1actualvalue - 0;
                                    } else {
                                        Admixture1 = 0;
                                    }
                                    var Admixture2 = null; //外加剂2
                                    if (
                                        res.data.dischargeinfo.fAdmixture2actualvalue != null &&
                                        res.data.dischargeinfo.fAdmixture2actualvalue != null
                                    ) {
                                        Admixture2 =
                                            res.data.dischargeinfo.fAdmixture2actualvalue - 0;
                                    } else {
                                        Admixture2 = 0;
                                    }
                                    // 水胶比=水/胶凝材料（水泥+矿粉+粉煤灰）
                                    var fWaterbinderratio =
                                        res.data.dischargeinfo.fWateractualvalue /
                                        (Cement1 + Cement2 + Oreactual + Flyashactual);
                                    this.formData.fWaterbinderratio =
                                        Math.floor(fWaterbinderratio * 100) / 100;

                                    // 外加剂掺量=外加剂/胶凝材料（水泥+矿粉+粉煤灰）*100
                                    var fAdditiveratio =
                                        ((Admixture1 + Admixture2) /
                                            (Cement1 + Cement2 + Oreactual + Flyashactual)) *
                                        100;
                                    this.formData.fAdditiveratio =
                                        Math.floor(fAdditiveratio * 100) / 100;
                                } else {
                                    this.$message.error(res.msg);
                                }
                            });
                        } else {
                            this.$message.error(res1.msg);
                            console.log("接口报错");
                        }
                    })
                    .catch((error) => {
                        console.log("拌合站设置编辑报错", error);
                    });
            } else {
                return this.$message.error("请先选择需要查看的数据");
            }
        },

        // 获取拌合机数据
        mixingPlantList(num, datas) {
            // // this.getList.fCompanyid this.checkData[0]
            var data = {
                companyId: datas.fCompanyid, // 施工标段id
                modelType: num, // 类型
                stationType: "1", // 拌合站类型
            };

            // this.bhzDataList = [];
            getStationmachineList(data)
                .then((res) => {
                    if (res.errcode == 0) {
                        var arr = res.data.stationmachineList;

                        // if (num == 1) {
                        //   this.bhjDataList = [
                        //     {
                        //       fItemName: "所有拌和机",
                        //       fItemValue: "",
                        //     },
                        //   ];
                        //   arr.map((item) => {
                        //     this.bhjDataList.push({
                        //       fItemName: item.fMachinename,
                        //       fItemValue: item.fMachineid
                        //     });
                        //   });
                        // } else
                        // if (num == 0) {
                        this.bhzDataList = [
                            {
                                fItemName: "所有拌和站",
                                fItemValue: "",
                            },
                        ];

                        arr.map((item) => {
                            this.bhzDataList.push({
                                fItemName: item.fMachinename,
                                fItemValue: item.fMachineid,
                            });
                        });
                        console.log(8888, this.bhzDataList);
                        // }
                    } else {
                        this.$message.error(res.msg);
                        return false;
                    }
                })
                .catch((error) => {
                    console.log(error);
                });
        },
        // 拌合站选择
        selectBhz(e) {
            console.log(e);
            this.getList.machineId = "";
            this.getbhjDataMethods(e);
            this.yj_searchForm(this.getList);
        },

        getbhjDataMethods(data) {
            getMachineListByStationId({ stationId: data })
                .then((res) => {
                    if (res.errcode == 0) {
                        var arr = res.data.stationmachineList;

                        this.bhjDataList = [
                            {
                                fItemName: "所有拌和机",
                                fItemValue: "",
                            },
                        ];
                        arr.map((item) => {
                            this.bhjDataList.push({
                                fItemName: item.fMachinename,
                                fItemValue: item.fMachineid,
                            });
                        });
                    } else {
                        this.$message.error(res.msg);
                        return false;
                    }
                })
                .catch((error) => {
                    console.log(error);
                });
        },
        // 时间间隔
        selectTime(e) {
            if (e[0] != "" && e[1] != "") {
                this.getList.startDates = e[0] + " " + "00:00:00"; // 开始时间
                this.getList.endDates = e[1] + " " + "23:59:59"; // 截至时间
                this.xlsxName = e[0] + "至" + e[1] + "混凝土拌和站记录数据";
            } else {
                this.getList.startDates = ""; // 开始时间
                this.getList.endDates = ""; // 截至时间
                this.xlsxName = "混凝土拌和站记录数据";
            }
            this.yj_searchForm(this.getList);
        },

        getDate() {
            if (JSON.parse(sessionStorage.getItem("GxEmbedded_getList"))) {
                this.getList = JSON.parse(sessionStorage.getItem("GxEmbedded_getList"));
                this.getList.page = 1;
                this.value2 = [this.getList.startDates, this.getList.endDates];
                this.xlsxName =
                    this.getList.startDates +
                    "至" +
                    this.getList.endDates +
                    "混凝土拌和站记录数据";
            } else {
                this.getList.startDates = this.common.getDay(-90) + " " + "00:00:00"; // 开始时间
                this.getList.endDates = this.common.getDay(0) + " " + "23:59:59"; // 截至时间
                this.value2 = [
                    this.common.getDay(-90) + " " + "00:00:00",
                    this.common.getDay(0) + " " + "23:59:59",
                ];
                this.xlsxName =
                    this.common.getDay(-90) +
                    "至" +
                    this.common.getDay(0) +
                    " " +
                    "23:59:59" +
                    "混凝土拌和站记录数据";
                console.log(this.getList);
            }
        },
        // 获取页面容器高度
        getHeight() {
            // var h = document.documentElement.clientHeight; //获取页面可见高度
            // this.dialogHeight = h * 0.50 + "px";
        },
        // 多选方法
        selectionChange() { },
        // 排序方法
        sortChange() { },
    },
};
</script>
    
<style scoped>
.TensionRealTime {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.printTables {
    background: #fff;
    display: flex;
    justify-content: end;
    padding: 5px;
    margin-top: 10px;
}

.dialogBody {
    /* padding: 3px 20px; */
    height: 99%;
    overflow-y: auto;
}

.baseTitle {
    /* border: 1px solid #0c204d; */
    border-bottom: 1px solid #0c204d;

    height: 30px;
    line-height: 30px;
    position: relative;
    padding-left: 15px;
}

.baseTitle::after {
    display: block !important;
    content: "";
    height: 30px;
    width: 5px;
    position: absolute;
    left: 0;
    top: 0;
    background: #0c204d;
}

.materialClass /deep/.el-table tr:nth-child(4) {
    display: none;
}
</style>